
import 'package:tdesign_flutter/tdesign_flutter.dart';
import 'package:test_app/routers/my/my_navigator.dart';

import 'my_state.dart';
import 'models/layout_list.dart';
import '../../core/base/base/base_logic.dart';


class MyController extends BaseLogic {

  final MyState myState = MyState();

  late final initDate = [
    LayoutList(title: 'text示例', description: 'text的应用场景', icon: TDIcons.ice_cream, onTap: toText),
    LayoutList(title: 'scroll_list扩展', description: '上拉刷新 下拉加载', icon: TDIcons.ice_cream, onTap: toScrollList),
    LayoutList(title: '表单扩展', description: '基于reactive_forms表单扩张', icon: TDIcons.ice_cream, onTap: toReactiveForms),
    LayoutList(title: '表单扩展', description: '基于flutter_form_builder表单扩张', icon: TDIcons.ice_cream, onTap: toBuilderForms),
  ];

  @override
  void initData() {
    super.initData();
    init();
  }

  void init() {
    myState.layoutList.clear();
    myState.layoutList.addAll(initDate);

    myState.count.value = 2;
  }

  void toText() {
    MyNavigator.toText();
  }

  void toScrollList() {
    MyNavigator.toScrollList();
  }

  void toReactiveForms() {
    MyNavigator.toReactiveForms();
  }

  void toBuilderForms() {
    MyNavigator.toBuilderForms();
  }

  void setSelected(selected) {
    myState.selected.value = '${selected[0]} ${selected[1]} ${selected[2]}';
    print('selected ------------$selected');
  }

}